package edu.Methods;

import java.util.Scanner;

public class Sort01 {
    public static void main(String[] args) {//升序
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入要排序的数的个数：");
        int a = scan.nextInt();
        int[] arr = new int[a];
        for (int i = 0; i < a; i++) {
            System.out.println("请输入第"+(i+1)+"个数：");
            Scanner scan1 = new Scanner(System.in);
            arr[i] = scan1.nextInt();
        }

        for (int i = 0; i <arr.length ; i++) {
            for (int j = 0; j <arr.length-i-1 ; j++) {

                if(arr[j] > arr[j+1]) {//(>)换成(<)为降序
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
        System.out.println("升序结果为：");
        for (int i : arr) {
            System.out.println(i);
        }
        System.out.println("共输出了"+arr.length+"个数！");
    }
}
